<!--  -->
<script setup>
import PopWindow from '@/components/PopWindow.vue'
import { ref } from 'vue'
import SubmitBtn from '@/components/button/SubmitBtn.vue'

defineProps(['condition', 'info'])
const emit = defineEmits(['close', 'submit'])

const checkboxList = ref([
  { id: 1, label: '垃圾信息', checked: false },
  { id: 2, label: '粗鲁，辱骂', checked: false },
  { id: 3, label: '其他', checked: false },
])

const form = ref({
  reason: [],
  info: '',
})

function submit() {
  form.value.reason = checkboxList.value.filter(v => v.checked).map(v => v.label)
  emit('submit', form.value)
}

</script>

<template>
  <PopWindow :condition="condition" @close="$emit('close')">
    <div class="pop-window-header">
      <div class="title">Report</div>
    </div>
    <div class="pop-window-body">
      <div class="label">被举报者信息</div>
      <p>{{ info }}</p>
      <div class="label">举报原因</div>
      <div v-for="v in checkboxList" :key="v.id" class="checkbox-container">
        <input v-model="v.checked" type="checkbox" :name="v.id" :id="v.id" />
        <label :for="v.id">{{ v.label }}</label>
      </div>
      <p class="label">附加信息</p>
      <textarea v-model="form.info"></textarea>
    </div>
    <div class="pop-window-footer">
      <SubmitBtn @click="submit">提交</SubmitBtn>
    </div>
  </PopWindow>
</template>

<style scoped lang="scss">
.pop-window-header {

  .title {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 2rem;
    color: var(--text-03);
  }
}

.pop-window-body {
  flex: 1;
  margin: 2em 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;

  .btn {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .checkbox-container {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .label {
    font-weight: 400;
    color: var(--text-02);

    .desc {
      margin-left: 10px;
      font-size: 0.8rem;
      color: #979797;
    }
  }

  .pop-window-footer {
    display: flex;
    justify-content: end;
  }
}

textarea {
  padding: 4px 11px;
  font-size: 14px;
  line-height: 1.5;
  color: #444c3f;
  outline: none;
  border: 1px solid #9cb294;
  background-color: var(--bgc-02);
  border-radius: 2px;
}

textarea {
  min-height: 50px;
  height: 50px;
  resize: vertical;
}
</style>
